package com.rongxun.common.utils;

import android.content.Context;

import com.umeng.analytics.MobclickAgent;

import java.util.HashMap;


/**
 * @ProjectName: yirabbit
 * @Package: com.shenzhen.yirabbit.utils
 * @ClassName: UMengEventUtils
 * @Description: 友盟事件统计处理
 * @Author: Mike
 * @CreateDate: 2020/5/18 10:29
 * @Version: 1.0
 */
public class UMengEventUtils {
    private        Context         mContext;
    private static UMengEventUtils instance;

    private UMengEventUtils(Context context) {
        this.mContext = context.getApplicationContext();
    }

    public static UMengEventUtils getInstance(Context context) {
        if (instance == null && context != null) {
            instance = new UMengEventUtils(context);
        }
        return instance;
    }

    /**
     * 用户登录
     */
    public void phoneLoginEvent() {
        HashMap<String, String> map = new HashMap<>();
        map.put("type", "phone");
        MobclickAgent.onEvent(mContext, "login", map);
    }

    /**
     * 客服点击
     */
    public void customerServiceEvent() {
        MobclickAgent.onEvent(mContext, "service");
    }

    /**
     * 通过推送进入app
     */
    public void pushEnterAppEvent() {
        MobclickAgent.onEvent(mContext, "push_enter_app");
    }

    /**
     * 首页活动弹窗点击
     */
    public void homeActivityEvent() {
        MobclickAgent.onEvent(mContext, "home_activity");
    }

    /**
     * 话题广场投票
     */
    public void topicVoteEvent() {
        MobclickAgent.onEvent(mContext, "topic_vote");
    }

    /**
     * 全球要闻点击
     */
    public void globalNewsEvent() {
        MobclickAgent.onEvent(mContext, "global_news");
    }

    /**
     * 每日解盘浏览
     */
    public void dailySolutionEvent() {
        MobclickAgent.onEvent(mContext, "daily_solution");
    }

    /**
     * 开屏广告点击
     */
    public void openScreenAdvertisementEvent() {
        MobclickAgent.onEvent(mContext, "launch_ad");
    }

    /**
     * 查看服务协议
     */
    public void serviceAgreementEvent(int type) {
        if (type == 1) {//同意查看服务协议
            MobclickAgent.onEvent(mContext, "agreement_agree");
        } else {
            MobclickAgent.onEvent(mContext, "agreement_refuse");
        }
    }
}
